package org.jivesoftware.smack.filter;

import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.util.StringUtils;

public class FromMatchesFilter
  implements PacketFilter
{
  private String address;
  private boolean matchBareJID = false;

  public FromMatchesFilter(String paramString)
  {
    if (paramString == null)
      throw new IllegalArgumentException("Parameter cannot be null.");
    this.address = paramString.toLowerCase();
    this.matchBareJID = "".equals(StringUtils.parseResource(paramString));
  }

  public boolean accept(Packet paramPacket)
  {
    boolean bool;
    if (paramPacket.getFrom() == null)
      bool = false;
    while (true)
    {
      while (true)
      {
        return bool;
        if (!(this.matchBareJID))
          break;
        bool = paramPacket.getFrom().toLowerCase().startsWith(this.address);
      }
      bool = this.address.equals(paramPacket.getFrom().toLowerCase());
    }
  }

  public String toString()
  {
    return "FromMatchesFilter: " + this.address;
  }
}